package com.wwdx.model.dto;

import com.wwdx.utils.ConfigReader;
import lombok.Data;

import java.io.File;
import java.io.Serializable;
import java.util.List;

/**
 * @author liguoliang
 * @date 2018/4/28 6:22
 */
@Data
public class MailDTO implements Serializable {
	/**
	 * 接口地址
	 */
	private String url;
	/**
	 * 接口名称
	 */
	private String apiUser;
	/**
	 * 接口密钥（apiUser vs apiKey 一对多关系）
	 */
	private String apiKey;
	/**
	 * 发信地址
	 */
	private String from;
	/**
	 * 发信名称
	 */
	private String fromName;
	/**
	 * 邮件地址
	 */
	private String email;
	/**
	 * 邮件标题
	 */
	private String subject;
	/**
	 * 邮件内容
	 */
	private String html;
	/**
	 * 邮件附件
	 */
	private List<File> attachments;

	public MailDTO(String email, String html, List<File> attachments) {
		String path = "/properties/constant.properties";
		ConfigReader configReader = new ConfigReader(path);
		this.email = email;
		this.html = html;
		this.attachments = attachments;
		this.url = configReader.get("mail.url");
		this.apiUser = configReader.get("mail.username");
		this.apiKey = configReader.get("mail.password");
		this.from = configReader.get("mail.sender");
		this.fromName = configReader.get("mail.fromname");
		this.subject = configReader.get("mail.subject");
	}
}